﻿<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <link href="/script/valid/css/tr.css" rel="stylesheet" /><!--判断如：PlatformName格式-->
    <script src="/script/config.js"></script>   
</head>

<body>
    <h5>购买会员样版配置</h5>
    <div class="form-body">
        <div class="form-horizontal  hide" id="form">

        </div>
    </div>
</body>
</html>
<script type="text/html" id="tp-form">

    <div class="form-group">
        <label class="col-sm-2">用户ID</label>
        <div class="col-md-6 col-sm-10">
            <input type="text" class="form-control" data-form="Customer_Id" placeholder="用户id" value="{{Customer_Id}}">
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2">充值金额</label>
        <div class="col-md-6 col-sm-10">
            <input type="text" class="form-control" data-form="Amount" placeholder="充值金额" value="{{Amount}}">
        </div>
    </div>


    <div class="form-group">
        <label class="col-sm-2">充值渠道</label>
        <div class="col-sm-2 col-sm-10">
            <label class="radio-reset">
                <input type="radio" name="n" data-form="Type" value="1" {{Type|radio_checked 1}}>
                <span>后台</span>
            </label>
            <label class="radio-reset">
                <input type="radio" name="n" data-form="Type" value="2" {{Type|radio_checked 2}}>
                <span>移动端</span>
            </label>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2">备注</label>
        <div class="col-md-6 col-sm-10">
            <textarea type="text" class="form-control" data-form="Memo" placeholder="接口默认后台充值" value="{{Memo}}"></textarea>
        </div>
    </div>


    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="button" id="btn-submit" class="btn btn-primary">提交</button>
          
        </div>
    </div>
</script>
<script src="/script/valid/form-valid.js?v=2018"></script>
<script>
    $(function () {
        var formValidEvent;
        var formValidInit = function () {
            var formValidData = [
                {
                    key: "Customer_Id",
                    datatype: "n",
                    nullmsg: "不能为空哦",
                    errormsg: "不能为空哦"
                },                
                {
                    key: "Amount",
                    datatype: "n",
                    nullmsg: "不能为空哦",
                    errormsg: "请正确输入金额！"
                },
                {
                    key: "Memo",
                    datatype: "*",
                    nullmsg: "不能为空哦",
                    errormsg: "请正确输入！"
                },

            ];
            formValidEvent = $(".form-body").formValid(formValidData);
        }
        var inintData = {
            Customer_Id: "",
            Type: 1,
            Amount: "",
            Memo: "",           
        };
        $("#form").templateRender({ el: "tp-form", data: inintData });//渲染模板，要先渲染才能获值
        formValidInit();

        $("#form").on("click", "#btn-submit", function () { //保存按钮有添加和编辑
            if (!formValidEvent.check()) { return; }
            var apiUrl = "recharge/recharge";            
            $("#form").ajaxFormSubmit(apiUrl, {
                pass: function (d) {
                
                    $.msgSucceed(d.Errmsg);
                    return
                },
                error: function (d) {
                    console.log(d)
                    $.msgFall(d.Errmsg);
                }
            })
            return
        });
    })

      
        


        


</script>
